from flask import  Flask
# 导入flask_session扩展
from flask_session import Session
# 导入sqlalchemy
from flask_sqlalchemy import SQLAlchemy
# 导入config
from config import config_dict


# 实例化sqlalchemy对象
db = SQLAlchemy()



def create_app(config_name):

    app = Flask(__name__)

    app.config.from_object(config_dict[config_name])

    # 让session扩展和程序实例化进行关联
    Session(app)

    db.init_app(app)
    # 导入蓝图
    from info.modules.news import news_blue
    app.register_blueprint(news_blue)


    return app